package com.yuju.rpt.dao.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.yuju.common.PageModel;
import com.yuju.common.util.bean.BeanUtil;
import com.yuju.order.model.ReserveModel;
import com.yuju.order.model.RoomOrderModel;
import com.yuju.rpt.dao.IRptOrderDao;
import com.yuju.rpt.dao.mapper.RptOrderMapper;
import com.yuju.util.Utils;

/**
 * 
 * 类名：RptOrderDaoImpl  <br />
 *
 * 功能：订单报表Dao接口实现
 *
 * @author : xuehj <br />
 * @Date : 2018年1月25日 下午1:50:37  <br />
 * @version : 1.1 <br />
 */
@Repository
public class RptOrderDaoImpl implements IRptOrderDao {
	@Autowired
	private RptOrderMapper rptOrderMapper;
	
	@Override
	public Integer checkoutCount(RoomOrderModel model) {
		Map<Object, Object> map = BeanUtil.getBeanMap(model);
		return rptOrderMapper.checkoutCount(map);
	}

	@Override
	public PageModel pageList(RoomOrderModel model, Integer page, Integer pageSize) {
		PageModel pageModel = new PageModel(page, pageSize);
		Map<Object, Object> map = BeanUtil.getBeanMap(model);
		Integer total = checkoutCount(model);
		
		// 记录数为空，则返回null
		if (total == 0) {
			return null;
		}
		
		// 设置总记录数到返回结果中
		pageModel.setTotal(total);
		
		List<RoomOrderModel> list = rptOrderMapper.checkoutList(map);
		
		pageModel.setRows(list);
		
		return pageModel;
	}

	@Override
	public List<RoomOrderModel> checkoutList(RoomOrderModel model) {
		Map<Object, Object> map = BeanUtil.getBeanMap(model);
		return rptOrderMapper.checkoutList(map);
	}

	@Override
	public List<ReserveModel> checkinList(ReserveModel model) {
		Map<Object, Object> map = BeanUtil.getBeanMap(model);
		Integer total = rptOrderMapper.checkinCount(map);
		if (total == 0) {
			return null;
		}
		
		List<ReserveModel> list = rptOrderMapper.checkinList(map);
		return list;
	}

}
